package com.yunxin.download.server.infra.constant.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * @author zero°
 * @since 2023-06-15
 */
@Getter
@RequiredArgsConstructor
public enum DownloadFileStatusEnum {

    /**
     * 文件状态 1.生成中,2.生成成功,3.生成失败,4.已过期
     */
    UN_KNOWN(0, "未知"),

    CREATING(1, "生成中"),

    CREATE_SUCCESS(2, "已生成"),

    CREATE_FAIL(3, "生成失败"),

    EXPIRED(4, "已过期"),


    ;

    private final Integer status;
    private final String description;

    public static DownloadFileStatusEnum getByStatus(int status){
        for (DownloadFileStatusEnum value : DownloadFileStatusEnum.values()) {
            if (value.status == status) {
                return value;
            }
        }
        return UN_KNOWN;
    }

}
